package com.example.dao;


import com.example.vo.UserAccess;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface UserAccessDAO extends JpaRepository<UserAccess, String> {

    UserAccess findByUserId(String userId);

    UserAccess findTopByUserIdOrPhone(String userId, String phone);

    @Query("select ua from UserAccess ua ")
    Page<UserAccess> findAllUserByPage(Pageable pageable);

    @Query("select ua from UserAccess ua where ua.userId = :keyword or ua.phone = :keyword ")
    Page<UserAccess> findAllUserByPageAndKeyword(Pageable pageable, @Param("keyword") String keyword);

}
